package com.codegenerate.demo.entity; /**
========= entity ==========
*/

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.time.LocalDateTime;


@TableName(value ="sys_account")
public class SysAccount implements Serializable {
  @TableId(value = "id", type = IdType.AUTO)
  private long id;



  
        
            /**
            * 服务器编号ID
            * long
            */
            @TableField(value = "server_number")
            private long serverNumber;
        

   
        
            /**
            * 最近更新时间
            * datetime
            */
            @TableField(value = "last_edit_time")
            @JsonDeserialize(using = LocalDateTimeDeserializer.class)		// 反序列化
            @JsonSerialize(using = LocalDateTimeSerializer.class)
            private LocalDateTime lastEditTime;
        

   
        
            /**
            * 最近更新人ID
            * long
            */
            @TableField(value = "edit_user_id")
            private long editUserId;
        

   
        
            /**
            * 最近更新人
            * string
            */
            @TableField(value = "edit_user")
            private String editUser;
        

   
        
            /**
            * 添加时间
            * datetime
            */
            @TableField(value = "add_time")
            @JsonDeserialize(using = LocalDateTimeDeserializer.class)		// 反序列化
            @JsonSerialize(using = LocalDateTimeSerializer.class)
            private LocalDateTime addTime;
        

   
        
            /**
            * 添加人ID
            * long
            */
            @TableField(value = "add_user_id")
            private long addUserId;
        

   
        
            /**
            * 添加人
            * string
            */
            @TableField(value = "add_user")
            private String addUser;
        

   
        
            /**
            * 有效状态[数据字典=del_state] 1有效  5删除
            * long
            */
            @TableField(value = "del_state")
            private long delState;
        

   
        
            /**
            * 租户ID
            * long
            */
            @TableField(value = "tenant_id")
            private long tenantId;
        

   
        
            /**
            * 租户类型 1应用管理者2应用消息者
            * long
            */
            @TableField(value = "tenant_type")
            private long tenantType;
        

   
        
            /**
            * 最近一次登录IP
            * string
            */
            @TableField(value = "last_ip")
            private String lastIp;
        

   
        
            /**
            * 最近登录时间
            * datetime
            */
            @TableField(value = "last_login_time")
            @JsonDeserialize(using = LocalDateTimeDeserializer.class)		// 反序列化
            @JsonSerialize(using = LocalDateTimeSerializer.class)
            private LocalDateTime lastLoginTime;
        

   
        
            /**
            * IP锁定可支持多个IP用逗号隔开
            * string
            */
            @TableField(value = "ip")
            private String ip;
        

   
        
            /**
            * ip锁定状态[查询]0未锁定1己锁定
            * long
            */
            @TableField(value = "ip_state")
            private long ipState;
        

   
        
            /**
            * 是否为超级管理员[查询]
            * long
            */
            @TableField(value = "is_admin")
            private long isAdmin;
        

   
        
            /**
            * 在线状态[数据字典=OnlieState]
            * long
            */
            @TableField(value = "onlie_state")
            private long onlieState;
        

   
        
            /**
            * 账号状态[数据字典=AccountState]  1正常  5己停用
            * long
            */
            @TableField(value = "state")
            private long state;
        

   
        
            /**
            * 累计登录次数
            * long
            */
            @TableField(value = "login_num")
            private long loginNum;
        

   
        
            /**
            * 登录密码
            * string
            */
            @TableField(value = "pass_word")
            private String passWord;
        

   
        
            /**
            * 登录用户名
            * string
            */
            @TableField(value = "user_name")
            private String userName;
        

   
        
        

   




        /**
        * region  set and get
        * */
    
           public long getServerNumber() {
             return serverNumber;
          }
          public void setServerNumber(long serverNumber) {
                 this.serverNumber = serverNumber;
          }   
   
           public LocalDateTime getLastEditTime() {
             return lastEditTime;
          }
          public void setLastEditTime(LocalDateTime lastEditTime) {
                 this.lastEditTime = lastEditTime;
          }   
   
           public long getEditUserId() {
             return editUserId;
          }
          public void setEditUserId(long editUserId) {
                 this.editUserId = editUserId;
          }   
   
           public String getEditUser() {
             return editUser;
          }
          public void setEditUser(String editUser) {
                 this.editUser = editUser;
          }   
   
           public LocalDateTime getAddTime() {
             return addTime;
          }
          public void setAddTime(LocalDateTime addTime) {
                 this.addTime = addTime;
          }   
   
           public long getAddUserId() {
             return addUserId;
          }
          public void setAddUserId(long addUserId) {
                 this.addUserId = addUserId;
          }   
   
           public String getAddUser() {
             return addUser;
          }
          public void setAddUser(String addUser) {
                 this.addUser = addUser;
          }   
   
           public long getDelState() {
             return delState;
          }
          public void setDelState(long delState) {
                 this.delState = delState;
          }   
   
           public long getTenantId() {
             return tenantId;
          }
          public void setTenantId(long tenantId) {
                 this.tenantId = tenantId;
          }   
   
           public long getTenantType() {
             return tenantType;
          }
          public void setTenantType(long tenantType) {
                 this.tenantType = tenantType;
          }   
   
           public String getLastIp() {
             return lastIp;
          }
          public void setLastIp(String lastIp) {
                 this.lastIp = lastIp;
          }   
   
           public LocalDateTime getLastLoginTime() {
             return lastLoginTime;
          }
          public void setLastLoginTime(LocalDateTime lastLoginTime) {
                 this.lastLoginTime = lastLoginTime;
          }   
   
           public String getIp() {
             return ip;
          }
          public void setIp(String ip) {
                 this.ip = ip;
          }   
   
           public long getIpState() {
             return ipState;
          }
          public void setIpState(long ipState) {
                 this.ipState = ipState;
          }   
   
           public long getIsAdmin() {
             return isAdmin;
          }
          public void setIsAdmin(long isAdmin) {
                 this.isAdmin = isAdmin;
          }   
   
           public long getOnlieState() {
             return onlieState;
          }
          public void setOnlieState(long onlieState) {
                 this.onlieState = onlieState;
          }   
   
           public long getState() {
             return state;
          }
          public void setState(long state) {
                 this.state = state;
          }   
   
           public long getLoginNum() {
             return loginNum;
          }
          public void setLoginNum(long loginNum) {
                 this.loginNum = loginNum;
          }   
   
           public String getPassWord() {
             return passWord;
          }
          public void setPassWord(String passWord) {
                 this.passWord = passWord;
          }   
   
           public String getUserName() {
             return userName;
          }
          public void setUserName(String userName) {
                 this.userName = userName;
          }   
   
           public long getId() {
             return id;
          }
          public void setId(long id) {
                 this.id = id;
          }   
   
        /**
        * endgion  set and get
        * */

 

    /**
        * build
        */
       public static SysAccount build(){
            SysAccount tempEntity = new SysAccount();
            return tempEntity;
    }

    public  static void setDefaultPassword(SysAccount temp){
        temp.setPassWord("123456");
    }
    /**
        * build
        */
       public  static void setDefaultValue(SysAccount temp){
              
                    if(temp.getServerNumber()<=0){
                                temp.setServerNumber(0L);
                    }        
            
                    if(null==temp.getLastEditTime()){
                                temp.setLastEditTime(LocalDateTime.now());
                    }        
            
                    if(temp.getEditUserId()<=0){
                                temp.setEditUserId(0L);
                    }        
            
                    if(StringUtils.isEmpty(temp.getEditUser())){
                                temp.setEditUser("");
                    }        
            
                    if(null==temp.getAddTime()){
                                temp.setAddTime(LocalDateTime.now());
                    }        
            
                    if(temp.getAddUserId()<=0){
                                temp.setAddUserId(0L);
                    }        
            
                    if(StringUtils.isEmpty(temp.getAddUser())){
                                temp.setAddUser("");
                    }        
            
                    if(temp.getDelState()<=0){
                                temp.setDelState(1);
                    }        
            
                    if(temp.getTenantId()<=0){
                                temp.setTenantId(0L);
                    }        
            
                    if(temp.getTenantType()<=0){
                                temp.setTenantType(0L);
                    }        
            
                    if(StringUtils.isEmpty(temp.getLastIp())){
                                temp.setLastIp("");
                    }        
            
                    if(null==temp.getLastLoginTime()){
                                temp.setLastLoginTime(LocalDateTime.now());
                    }        
            
                    if(StringUtils.isEmpty(temp.getIp())){
                                temp.setIp("");
                    }        
            
                    if(temp.getIpState()<=0){
                                temp.setIpState(0L);
                    }        
            
                    if(temp.getIsAdmin()<=0){
                                temp.setIsAdmin(0L);
                    }        
            
                    if(temp.getOnlieState()<=0){
                                temp.setOnlieState(0L);
                    }        
            
                    if(temp.getState()<=0){
                                temp.setState(0L);
                    }        
            
                    if(temp.getLoginNum()<=0){
                                temp.setLoginNum(0L);
                    }        
            
                    if(StringUtils.isEmpty(temp.getPassWord())){
                                temp.setPassWord("");
                    }        
            
                    if(StringUtils.isEmpty(temp.getUserName())){
                                temp.setUserName("");
                    }        
            
                    if(temp.getId()<=0){
                                temp.setId(0L);
                    }        
            


    }

    @JsonIgnore
    public LambdaQueryWrapper<SysAccount> getQueryAll() {
                 var  query = new QueryWrapper<SysAccount>().lambda();
        
                    if(this.serverNumber>0){
                                query.eq(SysAccount::getServerNumber, this.serverNumber);
                    }        
            
                    if(null!=this.lastEditTime){
                                query.eq(SysAccount::getLastEditTime, this.lastEditTime);
                    }        
            
                    if(this.editUserId>0){
                                query.eq(SysAccount::getEditUserId, this.editUserId);
                    }        
            
                    if(!StringUtils.isEmpty(this.editUser)){
                                query.eq(SysAccount::getEditUser, this.editUser);
                    }        
            
                    if(null!=this.addTime){
                                query.eq(SysAccount::getAddTime, this.addTime);
                    }        
            
                    if(this.addUserId>0){
                                query.eq(SysAccount::getAddUserId, this.addUserId);
                    }        
            
                    if(!StringUtils.isEmpty(this.addUser)){
                                query.eq(SysAccount::getAddUser, this.addUser);
                    }        
            
                    if(this.delState>0){
                                query.eq(SysAccount::getDelState, this.delState);
                    }        
            
                    if(this.tenantId>0){
                                query.eq(SysAccount::getTenantId, this.tenantId);
                    }        
            
                    if(this.tenantType>0){
                                query.eq(SysAccount::getTenantType, this.tenantType);
                    }        
            
                    if(!StringUtils.isEmpty(this.lastIp)){
                                query.eq(SysAccount::getLastIp, this.lastIp);
                    }        
            
                    if(null!=this.lastLoginTime){
                                query.eq(SysAccount::getLastLoginTime, this.lastLoginTime);
                    }        
            
                    if(!StringUtils.isEmpty(this.ip)){
                                query.eq(SysAccount::getIp, this.ip);
                    }        
            
                    if(this.ipState>0){
                                query.eq(SysAccount::getIpState, this.ipState);
                    }        
            
                    if(this.isAdmin>0){
                                query.eq(SysAccount::getIsAdmin, this.isAdmin);
                    }        
            
                    if(this.onlieState>0){
                                query.eq(SysAccount::getOnlieState, this.onlieState);
                    }        
            
                    if(this.state>0){
                                query.eq(SysAccount::getState, this.state);
                    }        
            
                    if(this.loginNum>0){
                                query.eq(SysAccount::getLoginNum, this.loginNum);
                    }        
            
                    if(!StringUtils.isEmpty(this.passWord)){
                                query.eq(SysAccount::getPassWord, this.passWord);
                    }        
            
                    if(!StringUtils.isEmpty(this.userName)){
                                query.eq(SysAccount::getUserName, this.userName);
                    }        
            
                    if(this.id>0){
                                query.eq(SysAccount::getId, this.id);
                    }        
            

           
            return  query;

    }

     @JsonIgnore
      public static LambdaQueryWrapper<SysAccount> getQuery(){
        var query = new QueryWrapper<SysAccount>().lambda();
        return query;
    }


  @JsonIgnore
     public LambdaUpdateWrapper<SysAccount> getUpdateWrapper() {
        var  updateWrapper = new UpdateWrapper<SysAccount>().lambda();
        
             if(this.serverNumber>0){ 
              
                         updateWrapper.set(SysAccount::getServerNumber, this.serverNumber);
              
                    }        
          
             if(null!=this.lastEditTime){ 
              
                         updateWrapper.set(SysAccount::getLastEditTime, this.lastEditTime);
              
                    }        
          
             if(this.editUserId>0){ 
              
                         updateWrapper.set(SysAccount::getEditUserId, this.editUserId);
              
                    }        
          
             if(!StringUtils.isEmpty(this.editUser)){ 
              
                         updateWrapper.set(SysAccount::getEditUser, this.editUser);
              
                    }        
          
             if(null!=this.addTime){ 
              
                         updateWrapper.set(SysAccount::getAddTime, this.addTime);
              
                    }        
          
             if(this.addUserId>0){ 
              
                         updateWrapper.set(SysAccount::getAddUserId, this.addUserId);
              
                    }        
          
             if(!StringUtils.isEmpty(this.addUser)){ 
              
                         updateWrapper.set(SysAccount::getAddUser, this.addUser);
              
                    }        
          
             if(this.delState>0){ 
              
                         updateWrapper.set(SysAccount::getDelState, this.delState);
              
                    }        
          
             if(this.tenantId>0){ 
              
                         updateWrapper.set(SysAccount::getTenantId, this.tenantId);
              
                    }        
          
             if(this.tenantType>0){ 
              
                         updateWrapper.set(SysAccount::getTenantType, this.tenantType);
              
                    }        
          
             if(!StringUtils.isEmpty(this.lastIp)){ 
              
                         updateWrapper.set(SysAccount::getLastIp, this.lastIp);
              
                    }        
          
             if(null!=this.lastLoginTime){ 
              
                         updateWrapper.set(SysAccount::getLastLoginTime, this.lastLoginTime);
              
                    }        
          
             if(!StringUtils.isEmpty(this.ip)){ 
              
                         updateWrapper.set(SysAccount::getIp, this.ip);
              
                    }        
          
             if(this.ipState>0){ 
              
                         updateWrapper.set(SysAccount::getIpState, this.ipState);
              
                    }        
          
             if(this.isAdmin>0){ 
              
                         updateWrapper.set(SysAccount::getIsAdmin, this.isAdmin);
              
                    }        
          
             if(this.onlieState>0){ 
              
                         updateWrapper.set(SysAccount::getOnlieState, this.onlieState);
              
                    }        
          
             if(this.state>0){ 
              
                         updateWrapper.set(SysAccount::getState, this.state);
              
                    }        
          
             if(this.loginNum>0){ 
              
                         updateWrapper.set(SysAccount::getLoginNum, this.loginNum);
              
                    }        
          
             if(!StringUtils.isEmpty(this.passWord)){ 
              
                         updateWrapper.set(SysAccount::getPassWord, this.passWord);
              
                    }        
          
             if(!StringUtils.isEmpty(this.userName)){ 
              
                         updateWrapper.set(SysAccount::getUserName, this.userName);
              
                    }        
          
             if(this.id>0){ 
              
                     updateWrapper.eq(SysAccount::getId, this.id);
              
                    }        
          


        return updateWrapper;
    }

}